recursive subroutine find_next(nlog,nxec,nstp,e,ne,in)
  use param
  use global
  use gi10
  implicit none
  integer,intent(in) :: nlog,nxec,nstp
  real(dbl),intent(in) :: e,ne
  integer,intent(in) :: in
  real(dbl) :: de,be,te,dh,h1,h2,ip
  real(dbl) :: se,sn,sig
  real(dbl) :: sum0,sum1,sum2
  integer :: i,j
  logical :: foo,boo
  ncall=ncall+1
  sum0=0.0
  foo=.true.
  te=e
  write(nlog,'(3x,"Call find_next (",i0,") Input energy=",1pe9.3)') ncall,e
!  write(*,'(3x,"Call find_next (",i0,") Input energy=",1pe9.3)') ncall,e
  call init_pptr(e)
  do while(foo)
     ! ------------------------------------- !
     ! int_{be-->te}
     be=te-ne
     if (be.le.sube) exit
     ! ------------------------------------- !
     ! int_{be-->n1-->n2-->...-->in-->te}
     dh=ne/real(in)
     sum1=0.0
!     call init_fptr(nlog,nxec,nstp,be)
     do i=in,1,-1
        h1=be+real(i)*dh
        h2=be+real(i-1)*dh
        sum2=0
        do j=1,ngi
           ip=0.5*(iqp(j)*dh+h1+h2)
           call get_estop(ip,se)
!           call read_nstop(nstp,ip,sn)
!           call read_xsec(nxec,ip,sig)
           call find_nstop(ip,sn)
           call find_xsec(ip,sig)
           sum2=sum2+iqw(j)*sig/(se+sn)
        end do
        sum2=0.5*dh*sum2
        sum1=sum1+sum2
     end do
     ! ------------------------------------- !
     sum0=sum0+sum1
     ! ------------------------------------- !
     if (sum0.ge.1) then
        de=e-be
        write(nlog,'(3x,"Found to make P=1 at E=",1pe9.3,1x,"dE=",1pe9.3)') be,de
!        write(*,'(3x,"Found to make P=1 at E=",1pe9.3,1x,"dE=",1pe9.3)') be,de
        if (de.le.sube) then
           n_split=n_split+1
           e_split(n_split)=de
        else
           call find_next(nlog,nxec,nstp,de,ne,in)
        end if
        if (be.le.sube) then
           n_split=n_split+1
           e_split(n_split)=be
           return
        else
           foo=.false.
           call find_next(nlog,nxec,nstp,be,ne,in)
        end if
     end if
     ! ------------------------------------- !
     te=be
  end do
  if (foo) then
     write(nlog,'(3x,"---- The end of find_next ----")')
     n_split=n_split+1
     e_split(n_split)=e
  end if
  return
end subroutine find_next
